# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=deathstar
pkgver=60.d7bcbfd
pkgrel=6
pkgdesc='Automate getting Domain Admin using Empire.'
groups=('blackarch' 'blackarch-automation' 'blackarch-exploitation')
arch=('any')
url='https://github.com/byt3bl33d3r/DeathStar'
license=('GPL3')
depends=('python' 'python-certifi' 'python-colorama' 'python-commonmark'
         'python-h11' 'python-httpcore' 'python-httpx' 'python-idna'
         'python-pygments' 'python-rfc3986' 'python-rich' 'python-sniffio'
         'python-typing_extensions')
makedepends=('git')
source=("$pkgname::git+https://github.com/byt3bl33d3r/DeathStar.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd $pkgname

  # lame and unnecessary packaging style (probably bored)... we hack around here
  sed -i 's|from deathstar.|from |g' "$pkgname/$pkgname.py"
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md

  cp -a "$pkgname/"* "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python $pkgname.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

